========== Exercise#1 ==========
Try the following regular expressions against the text below:

Regex#1: abcde
Regex#2: bc
Regex#3: bd
Regex#4: \t
Regex#5: \r or \n or \r\n

Text input: (Move your cursor to the next empty line before each search.)

abcde	(This is after a tab symbol.)
(This is a new line.)

========== Exercise#2 ==========
Regex: gr[ae]y
Regex: [a-z]   (Before using this, please CHECK the "Case sensitive" option.)
Regex: [A-Z]   (Before using this, please CHECK the "Case sensitive" option.)
Regex: [0-9]

Text: (Move your cursor to the next empty line before each search.)

gray
grey
Gray
Grey
graey
gr[ae]y
1 + 20 = 21

========== Exercise#3 ==========
Try these regexes against the above texts:
 
Regex: \d
Regex: \D
Regex: \w
Regex: \W
Regex: \s
Regex: \S

Regex: [^aeiou]
Regex: .
Regex: [^\n] or [^\r] or [^\r\n]


========== Exercise#4 ==========
Try these regexes against the above texts:

Regex: \w+
Regex: \s+
Regex: \d+

========== Exercise#5 ==========
Regex: regex|regular expression
Regex: regular expressions?
Regex: regex(es)?
Regex: reg(ular expressions?|ex(es)?)

Give Regexes a First Try

You can easily try the following yourself in a text editor that supports regular expressions, such as EditPad Pro. If you do not have such an editor, you can download the free evaluation version of EditPad Pro to try this out. EditPad Pro's regex engine is fully functional in the demo version. As a quick test, copy and paste the text of this page into EditPad Pro. Then select Search|Show Search Panel from the menu. In the search pane that appears near the bottom, type in regex in the box labeled "Search Text". Mark the "Regular expression" checkbox, and click the Find First button. This is the leftmost button on the search panel. See how EditPad Pro's regex engine finds the first match. Click the Find Next button, which sits next to the Find First button, to find further matches. When there are no further matches, the Find Next button's icon will flash briefly.

Now try to search using the regex reg(ular expressions?|ex(p|es)?) . This regex will find all names, singular and plural, I have used on this page to say "regex". If we only had plain text search, we would have needed 5 searches. With regexes, we need just one search. Regexes save you time when using a tool like EditPad Pro. Select Count Matches in the Search menu to see how many times this regular expression can match the file you have open in EditPad Pro.

If you are a programmer, your software will run faster since even a simple regex engine applying the above regex once will outperform a state of the art plain text search algorithm searching through the data five times. Regular expressions also reduce development time. With a regex engine, it takes only one line (e.g. in Perl, PHP, Java or .NET) or a couple of lines (e.g. in C using PCRE) of code to, say, check if the user's input looks like a valid email address.

========== Exercise#6 ==========

Possible regexes for matching dates: 

\d\d.\d\d.\d\d
\d\d[- /.]\d\d[- /.]\d\d
[0-1]\d[- /.][0-3]\d[- /.]\d\d
(0[1-9]|1[012])[- /.]([012]\d|3[01])[- /.]\d\d

(Find more delicate regexes for dates at: http://www.regular-expressions.info/dates.html)

Dates: (mm/dd/yy)

04/07/13
04-07-13
04507813
99/99/99
19/39/99

========== Exercise#7 ==========

Possible regexes for matching quotes:

Regex: ".*"
Regex: "[^"\r\n]*"
Regex: "[^"]*"

Texts with quotes:

#1: There is a "string" between double quotes.

#2: Houston, we have a problem with "string one" and "string two". Please respond.

#3: In the morning Anna Mikhaylovna said to Pierre:

"Yes, my dear, this is a great loss for us all, not to speak of you. But
God will support you: you are young, and are now, I hope, in command of
an immense fortune. The will has not yet been opened. I know you well
enough to be sure that this will not turn your head, but it imposes
duties on you, and you must be a man."

Pierre was silent.

========== Exercise#8 ==========
Matching HTML/XML tags

Regex: <([A-Z][A-Z0-9]*)\b[^>]*>.*?</\1>

Text:

Please go to the <a href="http://www.regular-expressions.info/" target="_blank">Regular-expressions.info website</a> for the complete tutorial about regular expressions!


